package br.ufrgs.inf.sissw.app;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.TextView;

/**
 * 
 * Base class that every basic{@link Activity} that comes from the dashboard
 * should implement.
 * 
 * @author matheus
 * 
 */
public abstract class AbstractDashboardActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		setContentView(getContentView());

		ImageButton homeButton = (ImageButton) findViewById(R.id.feature_home_button);
		homeButton.setOnClickListener(goHomeListener);

		TextView activityName = (TextView) findViewById(R.id.feature_name);
		activityName.setText(getFeatureNameResourceId());
	}

	private OnClickListener goHomeListener = new OnClickListener() {

		public void onClick(View v) {
			goHome(AbstractDashboardActivity.this);
		}
	};

	public void goHome(Context context) {
		final Intent intent = new Intent(context, InfAppActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		context.startActivity(intent);
	}

	protected abstract int getContentView();

	protected abstract int getFeatureNameResourceId();
}
